#include "sleep_action.h"

namespace action {

SleepAction::SleepAction(int tick) : remain_tick_(tick) { }

void SleepAction::onEvent(EventId event_id, void *event_data) {
  if (status() != Status::kRunning)
    return;

  if (event_id != EventId::kTimerTick)
    return;

  if (remain_tick_ > 0) {
    --remain_tick_;
    if (remain_tick_ == 0)
      finish();
  }
}

}
